{extend name="Base" /}
{block name="title"}{$title}{/block}
{block name="body"}
<link rel="stylesheet" type="text/css" href="/css/backend/custom.css?{:VER}"/>
<fieldset class="layui-elem-field layui-field-title">
	<legend>{$name}</legend>
</fieldset>

<form class="layui-form layui-form-pane">
	<div class="layui-form-item">
		<label class="layui-form-label">网站名称</label>
		<div class="layui-input-inline">
			<input type="text" name="APP_NAME" lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{$info.APP_NAME}">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">网站密钥</label>
		<div class="layui-input-inline">
			<input type="text" name="KEY" lay-verify="required" placeholder="用于网站加密相关的密钥，请勿泄漏" autocomplete="off" class="layui-input" value="{$info.KEY}">
		</div>
		<button type="button" class="layui-btn" title="随机生成密钥" onclick="randkey()">
			<i class="layui-icon">&#x1002;</i>
		</button>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">单页显示数量</label>
		<div class="layui-input-inline">
			<input type="text" name="LIMIT" lay-verify="required" placeholder="每个分页可以显示的最大数量，建议50" autocomplete="off" class="layui-input" value="{$info.LIMIT}">
		</div>
		<div class="layui-form-mid layui-word-aux">每个分页可以显示的最大数量，建议50</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">赠送上传流量</label>
		<div class="layui-input-inline">
			<input type="text" name="UPLOAD" placeholder="单位字节，1M=1048576；1G=1073741824" autocomplete="off" class="layui-input" value="{$info.UPLOAD}">
		</div>
		<div class="layui-form-mid layui-word-aux">单位字节，1M=1048576；1G=1073741824</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">赠送下载流量</label>
		<div class="layui-input-inline">
			<input type="text" name="DOWNLOAD" placeholder="单位字节，1M=1048576；1G=1073741824" autocomplete="off" class="layui-input" value="{$info.DOWNLOAD}">
		</div>
		<div class="layui-form-mid layui-word-aux">单位字节，1M=1048576；1G=1073741824</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">赠送积分</label>
		<div class="layui-input-inline">
			<input type="text" name="PRICE" placeholder="注册就送积分" autocomplete="off" class="layui-input" value="{$info.PRICE}">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">赠送永久邀请</label>
		<div class="layui-input-inline">
			<input type="text" name="INV" placeholder="注册就送永久邀请" autocomplete="off" class="layui-input" value="{$info.INV}">
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">邀请等级</label>
		<div class="layui-input-inline">
			<select name="INV_GROUP" id="INV_GROUP" title="选择用户组">
				<option value="">选择可以发送邀请的用户组</option>
			</select>
		</div>
		<div class="layui-form-mid layui-word-aux">注意：该选项不受制于是否开启邀请</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">验证邮箱</label>
		<div class="layui-input-inline">
			{if condition="ENABLED_VERIFY eq 'on'"}
			<input type="checkbox" name="ENABLED_VERIFY" lay-skin="switch" lay-text="开启|关闭" placeholder="" checked>
			{else/}
			<input type="checkbox" name="ENABLED_VERIFY" lay-skin="switch" lay-text="开启|关闭" placeholder="">
			{/if}
		</div>
		<div class="layui-form-mid layui-word-aux">设置新用户是否需要验证邮箱</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">关闭注册</label>
		<div class="layui-input-inline">
			{if condition="DISABLED_REG eq 'on'"}
			<input type="checkbox" name="DISABLED_REG" lay-skin="switch" lay-text="开启|关闭" placeholder="" checked>
			{else/}
			<input type="checkbox" name="DISABLED_REG" lay-skin="switch" lay-text="开启|关闭" placeholder="">
			{/if}
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">关闭邀请</label>
		<div class="layui-input-inline">
			{if condition="DISABLED_INV eq 'on'"}
			<input type="checkbox" name="DISABLED_INV" lay-skin="switch" lay-text="开启|关闭" placeholder="" checked>
			{else/}
			<input type="checkbox" name="DISABLED_INV" lay-skin="switch" lay-text="开启|关闭" placeholder="">
			{/if}
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">关闭网站</label>
		<div class="layui-input-inline">
			{if condition="DISABLED_WEB eq 'on'"}
			<input type="checkbox" name="DISABLED_WEB" lay-skin="switch" lay-text="开启|关闭" placeholder="" checked>
			{else/}
			<input type="checkbox" name="DISABLED_WEB" lay-skin="switch" lay-text="开启|关闭" placeholder="">
			{/if}
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">资源文件版本</label>
		<div class="layui-input-inline">
			<input type="text" name="VER" placeholder="JS、CSS的版本管理" autocomplete="off" class="layui-input" value="{$info.VER}">
		</div>
		<button type="button" class="layui-btn" title="自动填写版本号" onclick="gettimestamp()">
			<i class="layui-icon">&#x1002;</i>
		</button>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">Tracker地址</label>
		<div class="layui-input-inline">
			<input type="text" name="TRACKER" placeholder="Tracker地址" autocomplete="off" class="layui-input" value="{$info.TRACKER}">
		</div>
		<div class="layui-form-mid layui-word-aux">填写Tracker地址，如：https://wocnm.com/；留空为默认</div>
	</div>

	<div class="layui-form-item">
		<div class="layui-input-inline">
			<button class="layui-btn" lay-submit="" lay-filter="submit">提交</button>
		</div>
	</div>
</form>
<script>
	layui.use(['form', 'layer'], function () {
		var form = layui.form;
		var layer = layui.layer;

		$.ajax({
			type: "GET",
			url: "/backend/system/getConfig",
			cache: false,
			dataType: "json",
			success: function (data) {
				var INV_GROUP = data.data.group;
				for (var i_INV_GROUP in INV_GROUP) {
					var o_INV_GROUP = $("<option></option>");
					$(o_INV_GROUP).val(INV_GROUP[i_INV_GROUP]['id']);
					$(o_INV_GROUP).html(INV_GROUP[i_INV_GROUP]['name']);
					if (String(INV_GROUP[i_INV_GROUP]['id']) === String(data.data.INV_GROUP)) {
						$(o_INV_GROUP).attr("selected", "selected");
					}
					$("#INV_GROUP").append(o_INV_GROUP);
				}
				form.render('select');
			}
		});

		//监听提交
		form.on('submit(submit)', function (data) {
			var str = data.field;
			$.ajax({
				type: "POST",
				url: "/backend/system/doConfig",
				cache: false,
				data: str,
				dataType: "json",
				success: function (e) {
					if (e.status === 1) {
						layer.alert(e.message, {
							//成功图标
							icon: 1
						});
					} else if (e.status === 0) {
						layer.alert(e.message, {
							//失败图标
							icon: 2
						});
					} else {
						layer.alert("系统错误，请稍后重试", {
							//失败图标
							icon: 2
						});
					}
				}
			});
			return false;
		});
	});

	function gettimestamp() {
		var timestamp = new Date().getTime();
		$("input[name=VER]").val(timestamp);
	}

	function randkey() {
		var key = Math.random().toString(36).substr(2);
		$("input[name=KEY]").val(key);
	}
</script>
{/block}